/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.sdcache.distributed.client;


/**
 *
 * @author chaitanya
 */
public class ResponseHandler extends Thread
{
    private ClientSocketInterface server;
    private Processor processor;
    public  ResponseHandler(String name,ClientSocketInterface server,Processor processor)
    {
        super(name+" Response handler");
        this.server=server;
        this.processor=processor;
    }
    @Override
    public void run()
    {
        Object str=null;
        while(true){
            try{
            	int i=1;
                while(true)
                {
                    str = server.getObject();
                    //System.out.println("request-----------------------------"+str);
                    if(str!=null)
                        processor.process(str);
                }
            }catch(Exception e){
                System.out.println("Got Exception in processing the message "+str);
                e.printStackTrace();
            }
        }
    }
}
